package com.godofgamblers.hotelmanagementsystem.mapper;

import com.godofgamblers.hotelmanagementsystem.pojo.Comment;
import com.godofgamblers.hotelmanagementsystem.pojo.User;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;
@Repository
public interface CommentTextMapper {
    //通过room_type_id查询详情页面显示4条评论
    // 查询分页评论
    @Select("select * from type_comment where room_type_id=#{room_type_id} limit #{index},4")
    public List<Comment> findCommentByRtid(int room_type_id, int index);

    //按room_type_id查询评论数量
    @Select("SELECT COUNT(*) num from type_comment WHERE room_type_id=#{room_type_id}")
    public int CommentNumberByRtid(int room_type_id);

    //根据评论表中的user_id查询user表中的评论用户姓名
    @Select("select * from user where user_id=(select user_id from type_comment where room_type_id=#{room_type_id} limit 1)")
    public User findUserNameByUid(int room_type_id);



}


